

#include <linux/module.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/interrupt.h>

#include <asm/irq.h>
#include <asm/io.h>

MODULE_LICENSE("GPL");

struct input_dev *vkbd_dev;

static irqreturn_t key_interrupt(int irq, void *dummy)
{
	
}

void vkbd_timeout(unsigned long unused/*UNUSED*/)
{
	int x;

	for (x=0;x<4;x++) {
		input_report_key(vkbd_dev, KEY_Q, 1);
		input_sync(vkbd_dev);
		input_report_key(vkbd_dev, KEY_W, 0);
		input_sync(vkbd_dev);
	}
}

static int __init vkbd_init()
{


	/* Register interrupt */
	/*if(request_irq(BUTTON_IRQ, &key_interrupt, SA_INTERRUPT, "key", NULL) < 0) {
		printk(KERN_ERR "unable to register interrupt");
		return -EBUSY;
		}*/
	
	/* Device setup */
	vkbd_dev = input_allocate_device();

	vkbd_dev->name = "virtual keyboard device";
	vkbd_dev->phys = "phys_none";
	vkbd_dev->uniq = "Ultratronik vkboard";

	vkbd_dev->id.bustype = BUS_HOST;
	vkbd_dev->id.vendor = 0x0001;
	vkbd_dev->id.product = 0x0001;
	vkbd_dev->id.version = 0x0001;

	/* Define keys */
	set_bit(EV_KEY, vkbd_dev->evbit);

	set_bit(KEY_Q, vkbd_dev->keybit);
	set_bit(KEY_W, vkbd_dev->keybit);


	/* Register device */
	input_register_device(vkbd_dev);

	input_report_key(vkbd_dev, KEY_Q, 0);

	init_timer(&vkbd_dev->timer);
	vkbd_dev->timer.function = vkbd_timeout;
	vkbd_dev->timer.expires = jiffies + 4*HZ;
	add_timer(&vkbd_dev->timer);

	return 0;
}

static void __exit vkbd_exit()
{
	input_unregister_device(vkbd_dev);
	kfree(vkbd_dev);
}

module_init(vkbd_init);
module_exit(vkbd_exit);
